package com.javase;

public class ThisExercise {
    public static void main(String[] args) {
        Person04 p1 = new Person04("jack",50);
        Person04 p2 = new Person04("jack",50);
        System.out.println(p1.compareTo(p2));
    }
}
class Person04{
    String name;
    int age;
    public Person04(String name,int age){
        this.name = name;
        this.age = age;
    }
    public boolean compareTo(Person04 p){
//        if (this.name.equals(name)&&this.age == age){
//            return true;
//        }else {
//            return false;
//        }简写成以下代码
        return this.name.equals(p.name)&&this.age == p.age;
    }
}